<template>
  <div class="main">
    <div class="bg-bg"></div>
    <div class="content_box">
      <div class="headerBox">
        <div class="header">
          <div class="back" @click="goBack" v-if="routerIndex > 1">
            <van-icon name="arrow-left" />
          </div>
          <div class="title">{{ title }}</div>
        </div>
      </div>
      <div class="content">
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref, defineProps, onMounted } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();

const props = defineProps(["title"]);
const routerIndex = ref(1);

const goBack = () => {
  window.history.back();
};

onMounted(() => {
  routerIndex.value = router.currentRoute.value.meta.index;
});
</script>
<style lang="less" scoped>
.main {
  position: relative;
  width: 100%;
  height: 100%;
  font-family: PingFangSC-Medium, PingFang SC;
  background: rgba(244, 248, 251, 1);
  // background-image: url("~@/assets/bg.png");
  // background-size: 100% 100%;
  // background-repeat: no-repeat;
}

.content_box {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  padding: 0 24px;
  padding-top: 30px;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.bg-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 460px;
  background-image: url("@/assets/main-bg.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  z-index: 0;
}

.headerBox {
  .header {
    position: relative;

    .title {
      font-family: PingFangSC, PingFang SC;
      font-weight: 700;
      font-size: 30px;
      color: #333333;
      line-height: 42px;
      text-align: center;
      font-style: normal;
      width: 530px;
      margin: auto;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .back {
      cursor: pointer;
      position: absolute;
      left: 0;
      top: -10px;
      width: 40px;
      height: 40px;
      font-size: 40px;
      z-index: 10;
    }

    .content {}
  }
}
</style>